#include "Memory.h"
#include "mock/ArduinoMock.h"
#include "mock/MessageRouterMock.h"
#include "mock/LoggerMock.h"
using ::testing::_;
using ::testing::Return;
using ::testing::AnyNumber;

TEST(memoryCheck, isInfrastructure){
	ArduinoMock arduino;
	MessageRouterMock router;
	LoggerMock log;
	Memory mem(arduino, router, log);

	ASSERT_TRUE(mem.isInfrastructure());
}

TEST(memoryCheck, availableMemory){
	ArduinoMock arduino;
	MessageRouterMock router;
	LoggerMock log;
	Memory mem(arduino, router, log, 10);

	mem.tick(0);
	EXPECT_CALL(arduino, availableMem()).WillOnce(Return(1000));	
	EXPECT_CALL(router, postMessage(_, String("{\"dbg\":\"mem\", \"val\":\"1000\"}")))
		.Times(1);
	mem.tick(10);
	mem.tick(11);
	EXPECT_CALL(arduino, availableMem()).WillOnce(Return(1000));	
	EXPECT_CALL(router, postMessage(_, String("{\"dbg\":\"mem\", \"val\":\"1000\"}")))
		.Times(1);
	mem.tick(20);
}